package personal.learn.whiteboard;

import java.util.Scanner;

/**
 * nothing
 *
 * @author Chai yansheng
 * @create 2019/8/17
 **/
public class Main3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int days = scanner.nextInt();
        char[] works = new char[days];
        char[] bodys = new char[days];
        for (int i = 0; i < days; i++) {
            works[i] = (char) (scanner.nextInt() + 48);
        }
        for (int i = 0; i < days; i++) {
            bodys[i] = (char) (scanner.nextInt() + 48);
        }
        boolean awork = false;
        boolean abody = false;
        int busyDay = 0;
        for (int day = 0; day < days; day++) {
            if (works[day] == '1' && !awork) {
                awork = true;
                abody = false;
                busyDay++;
            }
            if (bodys[day] == '1' && !abody) {
                abody = true;
                awork = false;
                busyDay++;
            }
        }
        System.out.println(days - busyDay);
    }

}
